﻿/******************************************************************************

  Copyright (C), 2001-2011, DCN Co., Ltd.

 ******************************************************************************
  File Name     : bc_fifo.h
  Version       : Initial Draft
  Author        : tongzhilin
  Created       : 2019/11/1
  Last Modified :
  Description   : bc_fifo
  Function List :
  History       :
  1.Date        : 2019/11/1
    Author      : tongzhilin
    Modification: Created file

******************************************************************************/
#pragma once

#include <sched.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include <wchar.h>
#include <stddef.h>
#include <malloc.h>
#include <time.h>
#include <sys/types.h>
#include <ctype.h>
#include <errno.h>
#include <assert.h>
#include <signal.h>
#include <stdint.h>

#include <pthread.h>
#include <semaphore.h>
#include <time.h>
#include <sys/time.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/syscall.h>

typedef void* bc_fifo_handle;

#define FIFO_OUT

#define BC_FIFO_OK                  0
#define BC_FIFO_HANDLE_NULL        -1
#define BC_FIFO_PUSH_IN_NULL       -2
#define BC_FIFO_ERR_DROP_OLD_DATA  -3
#define BC_FIFO_ERR_DROP_NEW_DATA  -4

typedef enum
{
    FIFO_CYC = 1,           /*循环删除*/
    FIFO_DRP,               /*丢弃新数据*/
    FIFO_SEQ,               /*阻塞等待*/

    FIFO_CYC_AUTO = 11,     /*循环删除，自动回收*/
    FIFO_DRP_AUTO,          /*丢弃新数据，自动回收*/

    FIEO_TYPE_MAX
}BC_FIFO_TYPE_E;

bc_fifo_handle  fifo_Create(BC_FIFO_TYPE_E _type, int _max_count);
int             fifo_Destory(bc_fifo_handle _handle);
int             fifo_Pushin(bc_fifo_handle _handle, void* _data, int _len, void** _data_drop);
void*           fifo_Pullout(bc_fifo_handle _handle, int* FIFO_OUT _len);
int             fifo_GetNum(bc_fifo_handle _handle);
int             fifo_GetFifoInfo(char* _pcBuf, int _iSize);


